package com.cetc.sdp.kmga.cs.common;

import org.apache.hadoop.hbase.util.Bytes;
import scala.Tuple2;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @author： DengQiang
 * @date: 2017/8/25 9:40
 */
public class HbaseRecord implements Serializable {

    private byte[] family;

    private byte[] rowKey;

    private List<Tuple2<byte[], byte[]>> columns;

    public HbaseRecord() {
        this.columns = new ArrayList<>(64);
    }

    public byte[] getFamily() {
        return family;
    }

    public void setFamily(byte[] family) {
        this.family = family;
    }

    public byte[] getRowKey() {
        return rowKey;
    }

    public void setRowKey(byte[] rowKey) {
        this.rowKey = rowKey;
    }

    public void addColumn(String key, String val) {
        if (val != null && key != null && !val.isEmpty()) {
            columns.add(new Tuple2<>(Bytes.toBytes(key), Bytes.toBytes(val)));
        }
    }

    public List<Tuple2<byte[], byte[]>> getColumns() {
        return columns;
    }
}
